package com.ctshk.sapp.airexpress.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.airexpress.dto.AirportExpressInitializationSettingDTO;
import com.ctshk.rpc.airexpress.req.AirportExpressInitializationSettingsReq;
import com.ctshk.rpc.airexpress.service.IAirportExpressInitializationSettingsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;


import javax.validation.Valid;

/**
 * <p>
 * 机场快线api初始化设置表 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-02-18
 */
@RestController
@RequestMapping("/airport/express/initialization/settings")
@Api(value = "机场快线初始化设置", tags = "机场快线初始化设置")
public class AirportExpressInitializationSettingsController extends BaseController {
    @DubboReference
    IAirportExpressInitializationSettingsService airportExpressInitializationSettingsService;

    @ApiOperation(value = "机场快线初始化设置-保存", notes = "机场快线初始化设置-保存")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "机场快线初始化设置-保存", operDesc = "机场快线初始化设置-保存")
    @PostMapping("/save")
    public Result save(@Valid @RequestBody AirportExpressInitializationSettingsReq airportExpressInitializationSettingsReq) {
        Long userId = getCurrentUser(getRequest()).getId();
        return airportExpressInitializationSettingsService.save(airportExpressInitializationSettingsReq, userId);
    }

    @ApiOperation(value = "机场快线初始化设置-查询", notes = "机场快线初始化设置-查询")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "机场快线初始化设置-查询", operDesc = "机场快线初始化设置-查询")
    @GetMapping("/info")
    public Result<AirportExpressInitializationSettingDTO> getInfo() {
        return airportExpressInitializationSettingsService.selectInfo();
    }
}
